class Task68_3:
    def run(self, tree, node1, node2):
        node1_path = []
        node2_path = []
        self.get_path(tree, node1, node1_path)
        self.get_path(tree, node2, node2_path)

        if len(node1_path) < len(node2_path):
            node1_path, node2_path = node2_path, node1_path

        while len(node1_path) > len(node2_path):
            node1_path.pop()
        while node1_path[-1] is not node2_path[-1]:
            node1_path.pop()
            node2_path.pop()
        return node1_path[-1]

    def get_path(self, root, node, path):
        path.append(root)
        if node is root:
            return True
        for child in root.children:
            if self.get_path(child, node, path):
                return True
        path.pop()
        return False
